package jlib.component.animation
{
	public class AnimationGroup extends Animation {
		
		private var m_container:Vector.<Animation>;
		private var m_bReverse:Boolean;
		private var m_bStop:Boolean;
		
		public function AnimationGroup() {
			super();
			m_container = new Vector.<Animation>();
		}
		
		public function add($ani:Animation): void {
			m_container.push($ani);
		}
		
		public function getIndex($ani:Animation): int {
			return m_container.indexOf($ani);
		}
		
		public function contains($ani:Animation): Boolean {
			return m_container.indexOf($ani) > 0; 
		}
		
		public function removeAt($index:int): void {
			m_container.splice($index,0);
		}
		
		public function remove($ani:Animation): void {
			removeAt(m_container.indexOf($ani));
		}
		
		override public function start($param:*=null):void {
			m_bStop = false;
			for(var i:int=0;i<m_container.length;++i){
				m_container[i].start();
			}
		}
		
		override public function move($interpolate:*):void {
			for(var i:int=0;i<m_container.length;++i){
				var ani:Animation = m_container[i];
				if(ani.isStop()) continue ; 
				ani.move($interpolate);
			}
		}
		
		override public function stop($param:*=null):void {
			m_bStop = true;
			for(var i:int=0;i<m_container.length;++i){
				m_container[i].stop();
			}
		}
		
		override public function dealloc():void {
			unregist();
			for(var i:int=0;i<m_container.length;++i){
				m_container[i].dealloc();
			}
		}
		
		override public function reset(): void { 
			for(var i:int=0;i<m_container.length;++i){
				m_container[i].reset();
			}
		}
		
		override public function isStop():Boolean { return m_bStop; }
		
		override public function reverse():void  { m_bReverse = !m_bReverse; }
		
	}//c
}